package downloader;

import java.io.File;


abstract class AbstractFileDownloader implements Downloadable{

	protected String url = null;
	protected String localFileName = null;
	
	public AbstractFileDownloader(String url) {
		this.url = url;
		this.localFileName = fileName();
	}

	
	public String getFileName()
	{
		return localFileName;
	}
	
	private String fileName(){
		String fileName = null;
		if(url != null && url.length() > 0){
			int index = url.lastIndexOf("/");
			int qindex = url.indexOf("?");
			if(qindex > index){
				fileName = url.substring(index, qindex);
			}	else	{
				fileName = url.substring(index);
			}
		}
		return DOWNLOAD_DIR+fileName;
	}
	public static void main(String[] args) {
//		FileDownloader downloader = new FileDownloader("file:///C:/temp/model.xml");
//		downloader.download();
//		System.out.println("File Downloaded");
	}
}
